Extract the zip file somewhere, I'll be usingC:\libs\CppUTest
Go to the extracted CppUTest and open the fileCppUTest.sln
Build the solution:ctrl-shift-b
Run all of the tests:ctrl-F5
Verify the output resembles:
.......!!.........................................
..................................................
..............................................!...
..................................................
..........................!.................
OK (244 tests, 240 ran, 711 checks, 4 ignored, 0 filtered out, 0 ms)
Press any key to continue . . .
Press any key to close the cmd window opened while running your tests
Close the Solution:File:Close Solution
Creating a new Solution
Start Visual Studio 2008
Select:File:New:Project
Under Project Types, selectVisual C++
Under Templates, selectWin32 Console Application
Enter a project name, I'll useExample for these instructions
Enter a directory, I'll useC:\workspaces
ClickOK to continue configuring the project.
The Win32 Application Wizard window opens. ClickNexrt
On the Application Settings, selectEmpty Project under Additional options:
Confirm that theConsole Application radio button is selected.
ClickFinish.
Getting the Test Environment Configured
To setup some of the C++ properties, your project must have one .cpp file in in. We'll create that first and then finish setting up the project to be able to run unit tests.
Select your project, in my case its name is Example
Right-click and selectAdd:New Item
In the second column under Templates selectC++ File (.cpp)
For itsName, enterRunAllTests.cpp
ClickAdd
Edit the contents of the file, add the following code:
Now several project options are available to be set.
Select your project, Example in my case
Right-click and selectProperties
OpenConfiguration Properties:C/C++
On the right, the top entry is for Additional Include Directories. Edit that value and add the include directory for CppUTest. The actual directory should be the extracted directory for CppUTest with "\include" added. In my case, that'sC:\libs\CppUTest\include
OpenConfiguration Properties:Linker:Input
On the right, the top entry is Additional Dependencies. Edit that value and add the following two libraries:winmm.lib CppUTest.lib
OpenConfiguration Properties:Linker:General
On the right, near the bottom third of the list, you'll notice Additional Library Directories. Edit that value and include the lib directory for CppUTest. The actual directory should be the extracted directory for CppUTest with "\lib" added. In my case, that'sC:\libs\CppUTest\lib
OpenConfiguration Properties:C/C++:Preprocessor
On the right, the top entry is Preprocessor Definitions. Edit that value and add the following:;CPPUTEST_USE_STD_CPP_LIB=0. The full value of that field will beWIN32;_DEBUG;_CONSOLE;CPPUTEST_USE_STD_CPP_LIB=0
ClickOK to apply all of your changes.
Verify that you can build your solution:Ctrl-shift-b
You can now run your solution:Ctrl-F5 and you should see:
OK (0 tests, 0 ran, 0 checks, 0 ignored, 0 filtered out, 0 ms)
Press any key to continue . . .
Add a Test File
Now we'll add a single test file to verify that your system is up and running, although at this point if you have a running solution everything should work fine.
Note: We will be using just source files for our test code.
Add a source file to your project (see above for details on how). Call the fileFooTest.cpp
Overview
These instructions are for Version 2.3 of CppUTest and Visual Studio 2008.Setup for Visual Studio 2008
Creating a new Solution
Getting the Test Environment Configured
To setup some of the C++ properties, your project must have one .cpp file in in. We'll create that first and then finish setting up the project to be able to run unit tests.Now several project options are available to be set.
Add a Test File
Now we'll add a single test file to verify that your system is up and running, although at this point if you have a running solution everything should work fine.Note: We will be using just source files for our test code.
Congratulations, you're ready to get going.